import posts from './posts';

const lookup = new Map();
posts.forEach((post) => {
	lookup.set(post.slug, JSON.stringify(post));
});

export default {
	get(slug: string): unknown {
		return lookup.get(slug);
	},

	has(slug: string): boolean {
		return lookup.has(slug);
	},

	list(): unknown {
		const contents = JSON.stringify(
			posts.map((post) => {
				return {
					title: post.title,
					slug: post.slug,
					html: post.html,
				};
			})
		);
		return contents;
	}
};
